const {
    basePath,
    sourceDir,
    sourceDirJS,
    targetArr,
    allDirectory
} = require('./config')
const {gzipFile, cmdRun, zipDirtory} = require('./utils')

function formatTime(date) {
    const year = date.getFullYear();
    const month = (date.getMonth() + 1).toString().padStart(2, '0');
    const day = date.getDate().toString().padStart(2, '0');
    const hours = date.getHours().toString().padStart(2, '0');
    const minutes = date.getMinutes().toString().padStart(2, '0');
    const seconds = date.getSeconds().toString().padStart(2, '0');
    return `${year}${month}${day}_${hours}${minutes}${seconds}`;
  }
cmdRun(`node ./file_pack/main`).then(res=>{
    console.log('全部完毕')
    cmdRun(`md "${allDirectory}"`).then(res=>{
        console.log('开始压缩各个环境文件')
        cmdRun(`node ./file_pack/gzipfile`).then(res=>{
            console.log('开始打包所有文件')
            zipDirtory(allDirectory, allDirectory+formatTime(new Date())+'.zip')
        })
    })
})